package org.ucas.faker.web.dto;
import org.springframework.http.HttpStatus;
import org.ucas.faker.web.exceptions.ErrCode;

/**
 * 发生错误或异常的时候返回的消息格式体
 *
 * @author suemi
 */
public class ErrDto extends ResponseDto {
  
  //public static ErrDto WRONG_TOKEN = new ErrDto(HttpStatus.OK,null);
  public static ErrDto USER_NOTEXISTS = ErrDto.of(ErrCode.USER_NOTEXISTS);
  public static ErrDto WRONG_TOKEN = ErrDto.of(ErrCode.WRONG_TOKEN);
  
  public Integer errorCode;


  public ErrDto(int code, Integer errorCode, String message) {
    super(code, message);
    this.errorCode = errorCode;
  }

  public ErrDto(int code, String message) {
    this(code, null, message);
  }

  public ErrDto(int code, Integer errorCode){ this(code,errorCode,null); }

  public static ErrDto of(ErrCode errCode){
    ErrDto dto = new ErrDto(errCode.status.value(),errCode.getErrorCode(),errCode.message);
    return dto;
  }

  public Integer getErrorCode() {
    return errorCode;
  }

  public void setErrorCode(Integer errorCode) {
    this.errorCode = errorCode;
  }
}
